package org.langqiao.oop;

import java.util.*;

public class PointTest {
	
	public static void main(String[] args) {
		//MyPoint mp = new MyPoint(1.0,2.0);
		PointTest test = new PointTest();
		System.out.println(test.PointTest());
	}
	
	public int PointTest(){
		return 33333;
	}
}

class MyPoint{
	
	private double x;
	private double y;
	public MyPoint(double x,double y){
		this.x=x;
		this.y=y;
	}
	
	public static double distance(MyPoint p1,MyPoint p2) {
		double d1 = p1.x-p2.x;
		double d2 = p1.y-p2.y;
		return Math.sqrt(d1*d1+d2*d2);
	}
	
	//list中含有很多点的坐标，返回这些点中距离最小的距离
	public static double getMinDistance(List<MyPoint> list) {
		if(list == null || list.size() < 2)
			return Double.MAX_VALUE;
		double r = Double.MAX_VALUE;
		MyPoint p0 = list.remove(0);//相当于对集合进行遍历，集合中的 元素 的索引在不断地 变化
		for(int i = 0;i < list.size();i++) {
			MyPoint p = list.get(i);//获取list列表中 的点
			double d = MyPoint.distance(p0,p);
			if(d<r)
				r=d;
		}
		double d2=getMinDistance(list);//递归调用
		return d2>r?r:d2;//条件运算符，三目运算符
	}
}